<?php
/**
 * 这个页面的主要作用是显示每个分类中的一些商品的详细信息
 */
	include("db_fns.php");
	//session_start();
	$tid = $_GET["typeid"];
	$typename = get_typename($tid);
	
?>

<html>
<head> <title>some goods in  <?php echo $typename ?></title></head>

<body>
<?php 
 include("../include_htmls/header.php");   						//复用页面的头部
?>
<h1> <?php echo $typename ?> 的商品显示如下所示：</h1><br/>
<div id="categories" align="left">
<table>
<?php 
	/**
	 * 下边显示所有的分类的商品,首先从数据库中读取出商品的种类，然后以超链接的形式显示出来
	 */

	//session_start();
//	$types = getCategories(-1);
//	
//	$typeno = count($types);
//	
//	for($i = 0 ; $i < $typeno ; $i++)
//	{	
//		$typeid = $types[$i];
//		$typename = get_typename($typeid);
//		
//		/**
//		 * 跳转到每个分类，产看具体的商品
//		 */
//		
//		//$_SESSION["typeid"] = $typeid;
//		echo "<tr> <td><a href=\"http://localhost/e-commerce/cart/goodsintype.php?action=GET&typeid=$typeid\" >" .$typename. "</a></td></tr>";
//	}
	
?>

</table>
</div>

<div id="goods"> 

<table>


<?php 
/**
 * 每一行显示四个商品，显示两行
 */
echo "<tr>";

$goodsid = get_goods($tid);

$goods = count($goodsid);
//echo "typeid is : $tid and the goodsid is : $goodsid and the goods no is : $goods";
for($index = 0 ; $index < 4 ; $index ++)
{
	$gid = $goodsid[$index];
	
	$goods_baseinfo = get_goodsbinfo($gid);
	
	echo  "<td>";
	echo "<table>";
	$imagepath = get_imagepath($gid);
	echo "<tr> <td><a href=\" http://localhost/e-commerce/cart/goodsdetail.php?action=GET&gid=$gid\"><img src=$imagepath></a> </td></tr>";
//	echo "<br/>";
	$goodsname = $goods_baseinfo["gname"];
	echo "<tr><td>商品名称：".$goodsname."</td></tr>";
//	echo "<br/>";
	$goodsprice = $goods_baseinfo["gprice"];
	echo "<tr><td> 商品价格：$goodsprice </td></tr>";
	echo "</table>";
	echo "</td>";
//	echo "<br/>";
}

echo "</tr>";

echo "<br/>";
echo "<br/>";
echo "<br/>";
echo "<br/>";
echo "<br/>";

echo "<tr>";
for($index = 0 ; $index < 4 && ($index+4) < $goods; $index ++)
{
	$gid = $goodsid[$index+4];
	
	$goods_baseinfo = get_goodsbinfo($gid);
	
	echo  "<td>";
	echo  "<table>";
	$imagepath = get_imagepath($gid);
	echo "<tr><td> <a href=\"http://localhost/e-commerce/cart/goodsdetail.php?action=GET&gid=$gid\"><img src=$imagepath></a> </td></tr>";
//	echo "<br/>";
	$goodsname = $goods_baseinfo["gname"];
	echo "<tr><td>商品名称：".$goodsname."</td></tr>";
//	echo "<br/>";
	$goodsprice = $goods_baseinfo["gprice"];
	echo "<tr><td> 商品价格：$goodsprice </td></tr>";
	echo "</table>";
	echo "</td>";
}
echo "</tr>";
?>


</table>

</div>

</body>
</html>

